<?php
class Role extends AppModel {

	var $name = 'Role';
	var $validate = array(
		'name' => array('notempty')
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $hasMany = array(
		'User' => array(
			'className' => 'User',
			'foreignKey' => 'role_id',
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'counterQuery' => ''
		)
	);
	
  //tell Acl behavior (native cake) that the user will be a "requester" (aro)
	var $actsAs = array('Acl' => 'requester');
	/**
	 * The id of this parent node.
	 * @return null
	 */
	function parentNode() {
    if($this->id) {
      $data = $this->read();
      if(!empty($this->data) && $data['Role']['parent_id'])
        return array('Role' => array('id' => $data['Role']['parent_id']));
    } 
    return null;
	}
}
?>